package com.cpkso.buss.backend.security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * 跨域
 * @author wrzhxy@qq.com
 * @date 2017年12月7日
 */
public class HeaderInterceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		response.setHeader("Access-Control-Allow-Credentials", "true");
		// Get Post等方法允许请求
		// GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH
		response.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
		// 跨域 带cookie
//		response.setHeader("Access-Control-Allow-Origin", "http://localhost:9528");
		response.setHeader("Access-Control-Allow-Origin", "http://192.168.1.58:9528");
		return super.preHandle(request, response, handler);
	}

}
